package com.cheri.keller.common.Strategy;

import com.cheri.keller.common.util.QiniuUtils;
import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

public class UploadFileContext {

    private UploadFileStrategy uploadFileStrategy;

    public UploadFileContext(UploadFileStrategy uploadFileStrategy) {
        this.uploadFileStrategy = uploadFileStrategy;
    }

    /**
     * 上传文件 返回 上传成功后的 图片路径
     * @param multipartFile
     * @return
     * @throws IOException
     */
    public String uploadFile(MultipartFile multipartFile) throws IOException {

        return uploadFileStrategy.UploadFile(multipartFile);
    }

    /**
     * 根据文件名称删除
     * @param imgName
     * @return
     * @throws QiniuException
     */
    public Response deleFileByName(String imgName) throws QiniuException {

       return   uploadFileStrategy.deleFileByName(imgName);
    }


}
